{include file="common/header" /}
<body>
<head>
{include file="common/personal_top" /}
<!--用户中心样式-->
<div class="user_style clearfix">
 <div class="user_center clearfix">
   <!--左侧样式-->
    {include file="common/center" /}
 </div>
 <!--右侧样式属性-->
 <div class="right_style">
 <!--地址管理-->
  <div class="user_address_style">
    <div class="title_style"><em></em>地址管理</div> 
   <div class="add_address">
   <form action="{:url('personal/saveaddress')}" method="post">
    <span class="name">添加送货地址</span>
    <table cellpadding="0" cellspacing="0" width="100%">
     <tr><td class="label_name">收&nbsp;货&nbsp;&nbsp;人：</td><td><input name="consigner" type="text"  class="add_text" style=" width:100px"/><i>*</i></td></tr>
     <tr><td class="label_name">所在地区：</td><td>
             <select name="province" size="1" class="sel">
              <option value="0">--省份--</option>
              {volist name="province" id="prov"}
              <option value="{$prov.id}">{$prov.name}</option>
              {/volist}
            </select>
            <select name="city" size="1" class="sel2">
              <option value="0">--城市--</option>
            </select>
            <i>*</i></td></tr>
     <tr><td class="label_name">街道地址：</td><td><textarea name="detail_address" cols="" rows="" style=" width:500px; height:100px; margin:5px 0px"></textarea><i>*</i></td></tr>
     <tr><td class="label_name">邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;编：</td><td><input name="zip_code" type="text" class="add_text" style=" width:150px" placeholder="不清楚邮编填写000000" /><i>*</i></td></tr>
     <tr><td class="label_name">手&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机：</td><td><input name="mobile" type="text" class="add_text" style=" width:200px"/>&nbsp;&nbsp;(必填)</td></tr>
     <tr><td class="label_name">固定电话：</td>
     <td><input name="phone" type="text" class="add_text" style="width:60px" placeholder="区号"/>-<input name="" type="text" class="add_text" style="width:100px" placeholder="电话号码"/>-<input name="" type="text" class="add_text" style="width:60px" placeholder="分机号"/>&nbsp;&nbsp;(选填)</td></tr>
     <tr class="moren_dz" style="color: #999"><td class="label_name"></td><td><label><input name="ck" type="checkbox" value="1" />设置为默认地址</label></td></tr>
     <input type="hidden" name="uid" value="{$user->id}">
     <tr><td colspan="2" class="center"><input name="" type="submit" value="保存"  class="add_dzbtn"/><input name="" type="reset" value="清空"  class="reset_btn"/></td></tr>
    </table>
    </form>
   </div>
   <!--用户地址-->
   <div class="address_content">
    {if $count}
    <div class="address_prompt">以添加了 <strong>{$count}</strong> 条地址，最多保存添加15条地址</div>
    {else}
    <div class="address_prompt">您还没有任何收货地址，请先<a href="">添加</a></div>
    {/if}
    <table cellpadding="0" cellspacing="0" class="user_address" width="100%">
    <thead>
     <tr class="label"><td width="80px;">收货人</td><td width="180px;">所在地</td><td width="220px;">详细地址</td><td width="80px;">邮编</td><td width="120px;">电话/手机</td><td width="180px;">操作</td><td width="80px;"></td></tr>
     </thead>
     <tbody>
     {volist name="addrs" id="vo"}
      <tr>
	      <td>{$vo.consigner}</td>
	      <td>{$vo.province|getProvince}-{$vo.city|getProvince}</td>
	      <td>{$vo.detail_address}</td>
	      <td>{$vo.zip_code}</td>
	      <td>{$vo.mobile}</td>
	      <td><a href="{:url('personal/editAddress',['id'=>$vo.id])}">修改</a> | <a href="{:url('personal/deleteAddress',['id'=>$vo.id])}">删除</a></td>
	       <td>{if $vo.status == 1}<span style="border:1px solid #f90;color: #f90;">默认地址</span>{/if}</td>
      </tr>
      {/volist}
     </tbody>
    </table>
   </div>  
  </div>
 </div>
 </div>
 </div>
 {include file="common/footer" /}

 <script>
 var SCOPE = {
  'city_url': "{:url('personal/getCityById')}",
  };
$('.sel').change(function(){
  $('.sel2').empty();
  pid = $(this).val();
  if (pid == 0) {
  	$('.sel2').html('<option value="0">--城市--</option>');
  } else{
	  data = {'id':pid};
	  url = SCOPE.city_url;
	  $.post(url,data,function(result){
	    if (result.status == 1) {
	      data = result.data;
	      sec_html = '';
	        $(data).each(function(i){
	                  sec_html += "<option value='"+this.id+"'>"+this.name+"</option>";

	             });
	      $('.sel2').html(sec_html);
	    }else if(result.status == 0){
	      $('.sel2').html('');
	      return;
	    }
	  },'json');
	}
});
 </script>
</body>
</html>